package starfire.gui;

import java.awt.Graphics;
import java.awt.Insets;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.*;
import javax.swing.border.*;

public class MyButton extends JButton
    implements MouseListener
{

    protected Border m_raised;
    protected Border m_lowered;
    protected Border m_inactive;
  Border border1;

    public MyButton(String text,Icon icon)
    {
        super(text,icon);
        m_raised = new BevelBorder(BevelBorder.RAISED);
        m_lowered = new BevelBorder(BevelBorder.LOWERED);
        m_inactive = new EmptyBorder(2, 2, 2, 2);
     //  this.setBorderPainted(false);
       // setBorder(m_inactive);
       setBorder(null);
        setMargin(new Insets(1, 1, 1, 1));
        setToolTipText(text);
        addMouseListener(this);
        this.setAlignmentX(0.5f);
        this.setAlignmentY(0.5f);
        setRequestFocusEnabled(false);
    }

    public void paint(Graphics g) {
      if (this.getBorder()==null) {
        this.setBorder(m_inactive);
      // this.setBorderPainted(false);
      }
      super.paint(g);
    }

    public MyButton()
    {
      this(null,null);
    }

    public MyButton(String text)
    {
      this(text,null);
    }

    public void mouseClicked(MouseEvent mouseevent)
    {
    }

    public void mouseEntered(MouseEvent mouseevent)
    {
        setBorder(m_raised);
    }

    public void mouseExited(MouseEvent mouseevent)
    {
        setBorder(m_inactive);
    }

    public void mousePressed(MouseEvent mouseevent)
    {
        setBorder(m_lowered);
    }

    public void mouseReleased(MouseEvent mouseevent)
    {
        setBorder(m_inactive);
    }
}
